package cn.vshare.service.impl;

import cn.vshare.dao.RoleDao;
import cn.vshare.entity.Role;
import cn.vshare.service.RoleService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service("roleService")
public class RoleServiceImpl implements RoleService {

    @Resource
    private RoleDao roleDao;

    @Override
    public Role queryRoleById(Role role) {
        return roleDao.queryRoleById(role);
    }

    @Override
    public Role queryRoleByName(String name) {
        return roleDao.queryRoleByName(name);
    }

    @Override
    public List<Role> queryAllRole() {
        return roleDao.queryAllRole();
    }

    @Override
    public Page<Role> queryByConditions(Map<String,Object>map) {
        //使用分页助手,实质是拦截器
        Page page=PageHelper.startPage((int)map.get("pageNum"),(int)map.get("pageSize"));
        //多条件查询的角色信息列表
        List<Role>roleList=roleDao.queryByConditions(map);
        return page;
    }

    @Override
    public int addRole(Role role) {
        return roleDao.addRole(role);
    }

    @Override
    public int updateRole(Role role) {
        return roleDao.updateRole(role);
    }

    @Override
    public int deleteRole(String id) {
        return roleDao.deleteRole(id);
    }

    @Override
    public int addPermissionFirst2Role(Map<String, Object> map) {
        return roleDao.addPermissionFirst2Role(map);
    }

    @Override
    public int updatePermissionFirst2Role(Map<String, Object> map) {
        return roleDao.updatePermissionFirst2Role(map);
    }

    @Override
    public int deletePermissionFirst2Role(Map<String, Object> map) {
        return roleDao.deletePermissionFirst2Role(map);
    }

    @Override
    public Role queryPermissionFirstByRoleName(String name) {
        return roleDao.queryPermissionFirstByRoleName(name);
    }

    @Override
    public Role queryPermissionFirst2Role(Map<String, Object> map) {
        return roleDao.queryPermissionFirst2Role(map);
    }

    @Override
    public int addPermissionSecond2Role(Map<String, Object> map) {
        return roleDao.addPermissionSecond2Role(map);
    }

    @Override
    public int updatePermissionSecond2Role(Map<String, Object> map) {
        return roleDao.updatePermissionSecond2Role(map);
    }

    @Override
    public int deletePermissionSecond2Role(Map<String, Object> map) {
        return roleDao.deletePermissionSecond2Role(map);
    }

    @Override
    public Role queryPermissionSecondByRoleName(String name) {
        return roleDao.queryPermissionSecondByRoleName(name);
    }

    @Override
    public Role queryPermissionSecond2Role(Map<String, Object> map) {
        return roleDao.queryPermissionSecond2Role(map);
    }
}
